import 'package:casdon/app/config/theme/theme_extention.dart';
import 'package:flutter/material.dart';

class CommonTabBar extends StatelessWidget {
  final List<String> tabLabels;
  final TextStyle? selectedTextStyle;
  final TextStyle? normalTextStyle;
  final TabController? controller;
  final Color? indicatorColor;
  final double indicatorWeight;
  final EdgeInsets? labelPadding;
  final bool isScrollable;
  final Color dividerColor;


  const CommonTabBar({
    super.key,
    required this.tabLabels,
    this.selectedTextStyle,
    this.normalTextStyle,
    this.controller,
    this.indicatorColor,
    this.indicatorWeight = 2.0,
    this.labelPadding,
    this.isScrollable = true,
    this.dividerColor = Colors.transparent
  });

  @override
  Widget build(BuildContext context) {
    final effectiveSelectedTextStyle =
        selectedTextStyle ??
        context.textTheme.headlineLarge!.copyWith(
          color: context.colorScheme.primary,
        );
    final effectiveNormalTextStyle =
        normalTextStyle ??
        context.textTheme.headlineMedium!.copyWith(
          color: context.customColorThemeNonNull.textColor1,
        );
    final effectiveIndicatorColor =
        indicatorColor ?? context.colorScheme.primary;
    final effectiveLabelPadding =
        labelPadding ?? const EdgeInsets.symmetric(horizontal: 10.0);

    return TabBar(
      controller: controller,
      tabs: tabLabels.map((title) => Tab(text: title)).toList(),
      labelStyle: effectiveSelectedTextStyle,
      unselectedLabelStyle: effectiveNormalTextStyle,
      indicatorColor: effectiveIndicatorColor,
      indicatorWeight: indicatorWeight,
      labelPadding: effectiveLabelPadding,
      isScrollable: isScrollable,
      padding: EdgeInsets.zero,
      dividerColor: dividerColor,
      indicator: UnderlineTabIndicator(
        borderSide:  BorderSide(width: 2.0, color: effectiveIndicatorColor),
        insets: effectiveLabelPadding
      ),
    );

    
  }
}
